import request from '@/config/axios'

export interface PageParam {
  merchantId?: string // 商户id
  deviceSn?: string // 设备Sn
  orderId?: string // 订单id
  orderSn?:string // 订单编号
  taskStatus?:string // 任务状态
  createTime?:string[] // 设备创建时间mac
  printTime?:string[]   // 打印时间
  pageNo:number // 页码，从 1 开始
  pageSize:number // 每页条数，最大值为 100
}

export interface printerVo{
  merchantId: number, //商户id
  deviceSn: string, //设备序列号
  orderNo: number, 
  printContent:string, //打印内容
  printType: string, //打印类型：ORDER-订单 RECEIPT-小票
  expectPrintTime: string, //期望打印时间
  maxRetry: number //最大重试次数
}
// 获得列表
export const getPrinterPage = (params: PageParam) => {
  return request.get({ url: '/printer/task/page', params })
}
// 获得详情
export const getPrinterById = (id: number) => {
  return request.get({ url: `/printer/task/get?id=${id}` })
}
// 创建打印任务
export const createPrinter = (data: printerVo) => {
  return request.post({ url: '/printer/task/create', data })
}

// 删除打印任务
export const deletePrinterById = (id: number) => {
  return request.delete({ url: `/printer/task/delete?id=${id}` })
}

// 重试打印任务
export const retryPrinter = (taskId: string) => {
  return request.post({ url: `/printer/task/retry?taskId=${taskId}` })
}
// 取消打印任务
export const cancelPrinter = (taskId: string) => {
  return request.get({ url: `/printer/task/cancel?taskId=${taskId}` })
}
// 查询打印任务状态
export const queryPrinter = (taskId: string) => {
  return request.get({ url: `/printer/task/query-status?taskId=${taskId}` })
}